/**
 * 
 */
package com.gxa.ehome.service.impl;


import com.gxa.ehome.dao.AdminDao;
import com.gxa.ehome.dao.impl.AdminDaoImpl;
import com.gxa.ehome.entity.Admin;
import com.gxa.ehome.exception.BusinessException;
import com.gxa.ehome.service.AdminService;
import com.gxa.ehome.util.MD5Util;

/**
 * @author bilei
 * @date 2021年3月31日
 */
public class AdminServiceImpl implements AdminService {

	// UserDao对象解决具体的持久化操作
	AdminDao adminDao = new AdminDaoImpl();

	@Override
	public Admin login(String phone, String pwd) throws Exception {

		Admin loAdmin = adminDao.selectByName(phone);
//		System.out.println("service的"+loAdmin);
		if (loAdmin != null) {

			if (MD5Util.encode(pwd).equals(loAdmin.getPwd())) {
				return loAdmin;
			} else {
				throw new BusinessException("用户名或密码不正确");
			}
		} else {
			throw new BusinessException("不存在的用户");
//			return null;

		}


	}



}
